package demo.webauthn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import demo.webauthn.domain.WebAuthUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WebAuthUserMapper extends BaseMapper<WebAuthUser> {

    @Select("select * from web_auth_user where user_name = #{username}")
    List<WebAuthUser> selectByUsername(String username);

    @Select("select * from web_auth_user where algorithm = #{base64}")
    List<WebAuthUser> selectByAlgorithm(String base64);

    @Select("select * from web_auth_user where credential_id = #{credentialIdBase64} and algorithm = #{userAlgorithmBase64}")
    WebAuthUser selectOneByCredentialIdAndAlgorithm(String credentialIdBase64, String userAlgorithmBase64);

    @Select("select * from web_auth_user where credential_id = #{credentialId}")
    List<WebAuthUser> selectByCredentialId(String credentialId);

}
